package com.stylefeng.guns.core.util.appSecure;


/**
 * Description:
 *
 * @author
 * @version 2.0
 * @since 2017/8/25
 */
public class AESTest {

    public void testAES() {
        System.out.println("----------- start " + getNowTime() +
                " ------------");
        testInner("测试数据样本".getBytes(), "testtest");
        System.out.println("----------- end " + getNowTime() +
                " ------------");
        System.out.println();

        System.out.println("----------- start " + getNowTime() +
                " ------------");
        testInner("测试数据样本2".getBytes(), "testtest1");
        System.out.println("----------- end " + getNowTime() +
                " ------------");
        System.out.println();

        System.out.println("----------- start " + getNowTime() +
                " ------------");
        testInner("测试数据样本3".getBytes(), "testtest2");
        System.out.println("----------- end " + getNowTime() +
                " ------------");
        System.out.println();

        System.out.println("----------- start " + getNowTime() +
                " ------------");
        testInner("测试数据样本4".getBytes(), "testtest3");
        System.out.println("----------- end " + getNowTime() +
                " ------------");
        System.out.println();

    }

    private String getNowTime() {
        //return DateFormatUtil.format(DateFormatUtil.Format.HH_mm_ss, System.currentTimeMillis());
    	return "";
    }


    private void testInner(byte[] data, String password) {
        System.out.println("加密前:" + new String(data));

        byte[] encrypt = AESUtil.encrypt(data, password);

        System.out.println("加密后:" + HexUtil.encodeHexStr(encrypt));

        byte[] decrypt = AESUtil.decrypt(encrypt, password);

        System.out.println("解密后:" + HexUtil.encodeHexStr(decrypt));
        System.out.println("解密后:" + new String(decrypt));
    }

}
